<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>

<html>
	<head>
		<title>山西海宁皮革城</title>
		<%@ include file="/commons/meta.jsp"%>
		<script type="text/javascript">
		// 更新进度条
		//var progressFlagArray = new Array("false","false","false","false","false","false","false","false","false","false","false","false");
		var progressFlagArray = new Array(true,true,true,true,true,true,true,true);
		var progress = 8;
		//${progressCount};
		
		$(document).ready(function(){
			
			/* setup navigation, content boxes, etc... */
			Administry.setup();
			
			/* progress bar animations - setting initial values */
			Administry.progress("#edit_basic_progress", progress, 8);
			
			
			// validate form on keyup and submit
			var validator = $("#editBasicForm").validate({
				rules: {
					"travelAgencyName": {
						required: true,
					},
					"city": {
						required: true,
					},
					"contact": {
						required: true,
					},
					"mobile2": {
						required: true,
					},
					"address": {
						required: true,
					},
					"fax": {
						required: true,
					}
				},
				messages: {
					"travelAgencyName": {
						required: "请输入旅行社名称",
					},
					"city": {
						required : "请输入城市",
					},
					"contact": {
						required : "请输入联系人",
					},
					"mobile2": {
						required : "请输入联系电话",
					},
					"address": {
						required : "请输入地址",
					},
					"fax": {
						required : "请输入传真",
					},
					
				},
				// the errorPlacement has to take the layout into account
				errorPlacement: function(error, element) {
					error.insertAfter(element.parent().find('label:first'));
				},
				// specifying a submitHandler prevents the default submit, good for the demo
				//submitHandler: function() {
				//	alert("Data submitted!");
				//},
				// set new class to error-labels to indicate valid fields
				success: function(label) {
					// set &nbsp; as text for IE
					label.html("&nbsp;").addClass("ok");
				}
			});								
			
			
				$("#travelAgencyName").blur(function() {
					var obj = $("#travelAgencyName");
					if(obj.val() !=""){
						if(progressFlagArray[0] != true){
							progress += 1;
							progressFlagArray[0] = true;
							Administry.progress("#edit_basic_progress", progress, 8);
						}
					}else{
						if(progressFlagArray[0] == true){
							progress -= 1;
							progressFlagArray[0] = false;
							Administry.progress("#edit_basic_progress", progress, 8);
						}
					}
				});
				
				$("#city").blur(function() {
					var obj = $("#city");
					if(obj.val() !=""){
						if(progressFlagArray[2] != true){
							progress += 1;
							progressFlagArray[2] = true;
							Administry.progress("#edit_basic_progress", progress, 8);
						}
					}else{
						if(progressFlagArray[2] == true){
							progress -= 1;
							progressFlagArray[2] = false;
							Administry.progress("#edit_basic_progress", progress, 8);
						}
					}
				});
				
				$("#contact").blur(function() {
					var obj = $("#contact");
					if(obj.val() !=""){
						if(progressFlagArray[4] != true){
							progress += 1;
							progressFlagArray[4] = true;
							Administry.progress("#edit_basic_progress", progress, 8);
						}
					}else{
						if(progressFlagArray[4] == true){
							progress -= 1;
							progressFlagArray[4] = false;
							Administry.progress("#edit_basic_progress", progress, 8);
						}
					}
				});
				
				$("#mobile2").blur(function() {
					var obj = $("#mobile2");
					if(obj.val() !=""){
						if(progressFlagArray[5] != true){
							progress += 1;
							progressFlagArray[5] = true;
							Administry.progress("#edit_basic_progress", progress, 8);
						}
					}else{
						if(progressFlagArray[5] == true){
							progress -= 1;
							progressFlagArray[5] = false;
							Administry.progress("#edit_basic_progress", progress, 8);
						}
					}
				});
				
				$("#address").blur(function() {
					var obj = $("#address");
					if(obj.val() !=""){
						if(progressFlagArray[6] != true){
							progress += 1;
							progressFlagArray[6] = true;
							Administry.progress("#edit_basic_progress", progress, 8);
						}
					}else{
						if(progressFlagArray[6] == true){
							progress -= 1;
							progressFlagArray[6] = false;
							Administry.progress("#edit_basic_progress", progress, 8);
						}
					}
				});
				
				$("#fax").blur(function() {
					var obj = $("#fax");
					if(obj.val() !=""){
						if(progressFlagArray[7] != true){
							progress += 1;
							progressFlagArray[7] = true;
							Administry.progress("#edit_basic_progress", progress, 8);
						}
					}else{
						if(progressFlagArray[7] == true){
							progress -= 1;
							progressFlagArray[7] = false;
							Administry.progress("#edit_basic_progress", progress, 8);
						}
					}
				});
				
				
			
		});
		
		
		// 验证旅行社重复
		$(function(){
			$("#travelAgencyName").blur(function(){
				
				$.post(
					"prepareOpt!checkBasic.do",
					{travelAgencyName:$("#travelAgencyName").val()},
					function(data){
					
					//&& $("#txtVerifyCode").val().test(/^[a-z]+\w{2-5}@\w+.\w+.*\w*$/)
						if(data.ok ){
							$("#checkAgencyName").html("");
							index=true;
						}else{
							$("#checkAgencyName").html("<font color='red' style='padding-left:5px;font-weight:700'>旅行社已存在</font>");
							index=false;
						}
					},
					"json"
				);
			});
		});
		
		var index=true;
		function valid(){
			return  index;
		}
		
		</script>
	</head>

	<body>
		<%@ include file="/commons/top.jsp"%>
		<!-- Page title -->
		<div id="pagetitle">
			<div class="wrapper">
				<h1>Modify Base Information</h1>
				<s:if test="#session.login_user.permission == 1">
	 				<a href="${ctx }/pages/prepareInfo/add.jsp" class="btn"><span class="icon icon-add">&nbsp;</span>录入基本信息</a>
	 			</s:if>
			</div>
		</div>
		<!-- End of Page title -->
		
		<!-- Page content -->
		<div id="page">
			<!-- Wrapper -->
			<div class="wrapper">
					<div id="edit_basic_progress" class="progress full progress-green"><span><b></b></span></div>
					<!-- Left column/section -->
					<section class="column full first">					
						<form id="editBasicForm" method="post" action="prepareOpt!modifyBasic.do" onsubmit="return valid()">
							<fieldset>
								<legend>修改基本信息</legend>
								
								<div style="float:left;width:28%;margin-right:5%;">
									<p>
										<input type="hidden" id="agencyId" name="agencyId" value="<s:property value='#request.travelAgencyInfo.agencyId' />" />
										<label class="required" for="travelAgencyName">旅行社：</label><span id="checkAgencyName"></span><br/>
										<input type="text" id="travelAgencyName" class="full"  name="travelAgencyName" 
											value="<s:property value='#request.travelAgencyInfo.travelAgencyName' />" />
									</p>
								</div>
								
								<div style="float:left;width:28%;margin-right:5%;">
									<p>
										<label class="" for="payType">付款方式：</label><br/>
										<select id="payType" class="full"  name="payType">
											<option value="0" <s:if test="#request.travelAgencyInfo.payType == 0"> selected </s:if> >留存</option>
											<option value="1" <s:if test="#request.travelAgencyInfo.payType == 1"> selected </s:if> >现结</option>
										</select>
									</p>
								</div>
								
								<div style="float:left;width:28%;margin-right:5%;">
									<p>
										<label class="required" for="city">城市：</label><br/>
										<input type="text" id="city" class="full" name="city"
											value="<s:property value='#request.travelAgencyInfo.city' />" />
									</p>
								</div>
								
								<div style="float:left;width:28%;margin-right:5%;clear:both;">
									<p>
										<label class="" for="isContract">签约：</label><br/>
										<select id="isContract" class="full"  name="isContract">
											<option value="0" <s:if test="#request.travelAgencyInfo.isContract == 0"> selected </s:if> >未签</option>
											<option value="1" <s:if test="#request.travelAgencyInfo.isContract == 1"> selected </s:if> >已签</option>
										</select>
									</p>
								</div>
								
	
								<div style="float:left;width:28%;margin-right:5%;">
									<p>
										<label class="required" for="contact">联系人：</label><br/>
										<input type="text" id="contact" class="full"  name="contact"
											value="<s:property value='#request.travelAgencyInfo.contact' />" />
									</p>
								</div>
								
								<div style="float:left;width:28%;margin-right:5%;">
									<p>
										<label class="required" for="mobile2">联系电话：</label><br/>
										<input type="text" id="mobile2" class="full"  name="mobile2"
											value="<s:property value='#request.travelAgencyInfo.mobile' />" />
									</p>
								</div>
								
								<div style="float:left;width:28%;margin-right:5%;clear:both;">
									<p>
										<label class="required" for="address">公司地址：</label><br/>
										<input type="text" id="address" class="full"  name="address"
											value="<s:property value='#request.travelAgencyInfo.address' />" />
									</p>
								</div>
								<div style="float:left;width:28%;margin-right:5%;">
									<p>
										<label class="required" for="fax">传真：</label><br/>
										<input type="text" id="fax" class="full"  name="fax"
											value="<s:property value='#request.travelAgencyInfo.fax' />" />
									</p>
								</div>
								
								<div style="clear:both;padding-top:15px;">
									<p class="box"><input type="submit" class="btn btn-green big" value="修改"/> or <input type="reset" class="btn" value="重置"/></p>
								</div>
							</fieldset>
						</form>
						
						<div class="clear">&nbsp;</div>
						
					</section>
					<!-- End of Left column/section -->
					
					
			</div>
			<!-- End of Wrapper -->
		</div>							
		<!-- End of Page content -->
		
		<!-- Page footer -->
		<%@ include file="/commons/footer.jsp"%>
		<!-- End of Page footer -->
		
		<!-- Scroll to top link -->
		<a href="#" id="totop">^ scroll to top</a>
	
		<!-- User interface javascript load -->
		<script type="text/javascript" SRC="js/administry.js"></script>
	</body>
</html>
